#ifndef __TREE_H__
#define __TREE_H__

struct _tree_datatype {
	void *value;
	size_t sz;
};

typedef struct _tree_datatype TDT;

struct _pair {
	TDT key;
	TDT value;
};

typedef struct _pair Pair;
struct _tree_iface {
	int (*compare_key)(TDT a, TDT b);
	int (*compare_value(TDT a, TDT b);
	int (*clone_key)(TDT a, TDT* b);
	int (*free_key)(TDT c);
	int (*clone_value)(TDT a, TDT* b);
	int (*free_value)(TDT a);
};

typedef struct _tree_iface TreeInterface;

typedef struct _tree Tree;

int tree_create(const TreeInterface* iface, Tree** result);
int tree_insert(Tree* tree, Pair* pair);
int tree_search(Tree* tree, Pair* pair, int (*callback)(Pair* pair, void* data), void* data);
int tree_remove(Tree* tree, Pair* pair);
int tree_delete(Tree* tree);

#endif 
